<script setup>
import {useRouter} from "vue-router";

const {proxy} = getCurrentInstance();
const router = useRouter();
const {ky_yw, ky_jcjb, ky_hrjgl, ky_sf, ky_yjqk, ky_yyxjg, ky_xys, ky_jcjg, sys_user_sex} =
    proxy.useDict("ky_yw", "ky_jcjb", "ky_hrjgl", "ky_sf", "ky_yjqk", "ky_yyxjg", "ky_xys", "ky_jcjg", "sys_user_sex");
const form = ref({
  tysId: "",
});
const rules = {
  name: [{required: true, message: "请输入参与者姓名", trigger: "blur"}],
  phone: [{required: true, message: "请输入联系电话", trigger: "blur"}],
  age: [{required: true, message: "请输入年龄", trigger: "blur"}],
};
const props = defineProps({
  showAction: {
    type: Boolean,
    default: false,
  },
  tysObject: {
    type: Object,
    default: () => {
      return {
        patientName: "",
        phoneMobile: "",
        tysId: "",
      }
    }
  }
});

onMounted(() => {
  console.log('传入参数：', props.tysObject);
  form.value.patientName = props.tysObject.patientName;
  form.value.phone = props.tysObject.phoneMobile;
  form.value.tysId = props.tysObject.id;
});

const cancelSave = () => {
  router.replace("/keyan/patient");
};


//暴露state和play方法
defineExpose({
  form,
});
</script>
<template>
  <div class="app-container">
    <el-form
        :inline="true"
        :model="form"
        ref="ruleFormRef"
        :rules="rules"
        label-width="auto"
        label-position="right"
    >
      <el-input v-model="form.tysId" style="display: none"/>
      <el-divider content-position="left">基础信息</el-divider>
      <el-row>
        <el-col :span="6">
          <el-form-item label="参与者姓名" prop="name">
            <el-input
                v-model="form.patientName"
                placeholder="请输入参与者姓名"
                clearable
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="联系电话" prop="phone">
            <el-input
                v-model="form.phone"
                placeholder="请输入联系电话"
                clearable
            />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="6">
          <el-form-item label="性别" prop="age">

            <el-select
                v-model="form.wxysdj"
                placeholder="性别"
                clearable
                style="width: 190px"
            >
              <el-option
                  v-for="dict in sys_user_sex"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="年龄" prop="age">
            <el-input v-model="form.age" placeholder="年龄" clearable>
              <template #append>岁</template>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="身高">
            <el-input
                v-model="form.height"
                placeholder="身高"
                clearable
            >
              <template #append>cm</template>
            </el-input>
          </el-form-item>
        </el-col>

        <el-col :span="6">
          <el-form-item label="体重">
            <el-input
                v-model="form.weight"
                placeholder="体重"
                clearable
            >
              <template #append>kg</template>
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="6">
          <el-form-item label="基础疾病">
            <el-select
                v-model="form.jcjb"
                placeholder="请选择基础疾病"
                clearable
                style="width: 190px"
            >
              <el-option
                  v-for="dict in ky_jcjb"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item
          >
        </el-col>

        <el-col :span="6">
          <el-form-item label="吸烟史">
            <el-select
                v-model="form.xys"
                placeholder="吸烟史"
                clearable
                style="width: 190px"
            >
              <el-option
                  v-for="dict in ky_xys"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="饮酒情况">
            <el-select
                v-model="form.yjqk"
                placeholder="饮酒情况"
                clearable
                style="width: 190px"
            >
              <el-option
                  v-for="dict in ky_yjqk"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="红肉或加工类饮食">
            <el-select
                v-model="form.hrjgl"
                placeholder="红肉或加工类饮食"
                clearable
                style="width: 190px"
            >
              <el-option
                  v-for="dict in ky_hrjgl"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
              />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="6">
          <el-form-item label="有无一级亲属患有结直肠癌">
            <el-select
                v-model="form.jzcaqsYw"
                placeholder="有无一级亲属患有结直肠癌"
                clearable
                style="width: 190px"
            >
              <el-option
                  v-for="dict in ky_yw"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="与参与者关系">
            <el-input
                v-model="form.jzcaqsGx"
                placeholder="请输入与参与者关系"
                clearable
            />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="6">
          <el-form-item label="最近是否做过肠镜检查">
            <el-select
                v-model="form.cjjcSf"
                placeholder="最近是否做过肠镜检查"
                clearable
                style="width: 190px"
            >
              <el-option
                  v-for="dict in ky_sf"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="肠镜检查时间">
            <el-date-picker
                style="width: 190px"
                v-model="form.cjjcSj"
                value-format="YYYY-MM-DD"
                type="date"
                placeholder="肠镜检查时间"
            />
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="肠镜检查结果" style="width: 100%">
            <el-input
                v-model="form.cjjcJg"
                placeholder="肠镜检查结果"
                clearable
                style="width: 100%"
            />
          </el-form-item>
        </el-col>

      </el-row>

      <el-divider content-position="left">肿瘤标志物和肠镜检查结果信息</el-divider>

      <el-row>
        <el-col :span="6">
          <el-form-item label="Septin9检查结果">
            <el-select
                v-model="form.s9"
                placeholder="请选择Septin9检查结果"
                clearable
                style="width: 190px"
            >
              <el-option
                  v-for="dict in ky_yyxjg"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item
          >
        </el-col>

        <el-col :span="6">
          <el-form-item label="FIT-DNA结果">
            <el-select
                v-model="form.fitDna"
                placeholder="FIT-DNA结果"
                clearable
                style="width: 190px"
            >
              <el-option
                  v-for="dict in ky_yyxjg"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
              />
            </el-select>
          </el-form-item>
        </el-col>


        <el-col :span="6">
          <el-form-item label="CA19-9检查结果">
            <el-select
                v-model="form.ca199"
                placeholder="CA19-9检查结果"
                clearable
                style="width: 190px"
            >
              <el-option
                  v-for="dict in ky_jcjg"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
              />
            </el-select>
          </el-form-item>
        </el-col>

        <el-col :span="6">
          <el-form-item label="CA19-9检查异常结果">
            <el-input
                v-model="form.ca199Jg"
                placeholder="CA19-9检查异常结果"
                clearable
            />

          </el-form-item>
        </el-col>
      </el-row>

      <el-row>

        <el-col :span="6">
          <el-form-item label="CEA检查结果">
            <el-select
                v-model="form.cea"
                placeholder="CEA检查结果"
                clearable
                style="width: 190px"
            >
              <el-option
                  v-for="dict in ky_jcjg"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
              />
            </el-select>

          </el-form-item>
        </el-col>

        <el-col :span="6">
          <el-form-item label="CEA异常结果">
            <el-input
                v-model="form.ceaJg"
                placeholder="CEA异常结果"
                clearable
            />
          </el-form-item>
        </el-col>
        <!--        <el-col :span="6">-->
        <!--          <el-form-item label="肠镜">-->


        <!--            <el-select-->
        <!--                v-model="form.cj"-->
        <!--                placeholder="肠镜结果"-->
        <!--                clearable-->
        <!--                style="width: 190px"-->
        <!--            >-->
        <!--              <el-option-->
        <!--                  v-for="dict in ky_jcjg"-->
        <!--                  :key="dict.value"-->
        <!--                  :label="dict.label"-->
        <!--                  :value="dict.value"-->
        <!--              />-->
        <!--            </el-select>-->

        <!--          </el-form-item>-->
        <!--        </el-col>-->

        <!--        <el-col :span="6">-->
        <!--          <el-form-item label="肠镜异常结果">-->
        <!--            <el-input-->
        <!--                v-model="form.cjJg"-->
        <!--                placeholder="肠镜异常结果"-->
        <!--                clearable-->
        <!--            />-->

        <!--          </el-form-item>-->
        <!--        </el-col>-->

      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="其它肿瘤标志物">
            <el-input
                v-model="form.qtzlbzw"
                style="width: 500px"
                :rows="2"
                type="textarea"
                placeholder="输入其它肿瘤标志物"
            />
          </el-form-item>
        </el-col>
      </el-row>
      <el-divider content-position="left">治疗建议</el-divider>
      <el-row>
        <el-col :span="12">
          <el-form-item label="治疗建议">
            <el-input
                v-model="form.cjJg"
                style="width: 500px"
                :rows="2"
                type="textarea"
                placeholder="治疗建议"
            />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<style lang="scss" scoped>
.app-container {
  background: #f5f5f5;
}

:deep(.el-divider__text) {
  color: #888888;
  font-weight: normal;
}
</style>
